import store from "@/store";

export function roleCheck(name) {
  try {
    if (!name) {
      return false;
    }
    if (name.includes("userinfo")) {
      return true;
    }
    let roles = store.getters.roleInfo || {},
      keys = Object.keys(roles);

    if (keys.includes(name)) {
      return roles[name].isShow;
    } else {
      for (let item of keys) {
        if (roles[item][name]) {
          return roles[item][name].isShow;
        }
      }
    }
  } catch (err) {
    console.log(err);
    return false;
  }
  return true;
}
